package translator;

import java.io.IOException;
import java.util.Set;
import org.eclipse.swt.widgets.Display;
import translator.messages.Messages;
import translator.provider.SeznamTranslator;
import translator.storage.Storage;
import translator.ui.MainScreen;

public class Main {

    private static MainScreen mainScreen = null;

    public static void main(String[] args) throws IOException {

        Messages.setLanguage(Messages.ELang.CZ);

        showMainScreen();

    }

    private static void showMainScreen() {
        if(mainScreen != null) {
            mainScreen.setVisible(true);
        } else {
            Display display = new Display();
            mainScreen = new MainScreen(display);
            mainScreen.show();
        }
    }

    private static void test() throws IOException {
        String word = "gig";

        SeznamTranslator translator = new SeznamTranslator(SeznamTranslator.ELang.ENGLISH, SeznamTranslator.ELang.CZECH);
        Set<String> result = translator.translate("gig");
        System.out.println("for gig: " + result);

        Storage storage = new Storage(Storage.ETranslate.EN_CZ_FILE);
        storage.add(word, result);

        result = storage.translate(word);
        System.out.println("gig from storage: " + result);
    }

}
